namespace DotNetNuke.Security.Permissions
{
    using System;
    using System.Collections;
    using System.Reflection;

    public class TabPermissionCollection : CollectionBase
    {
        public TabPermissionCollection()
        {
        }

        public TabPermissionCollection(ArrayList TabPermissions)
        {
            int refIntHelperL0 = TabPermissions.Count - 1;
            for (int i = 0; i <= refIntHelperL0; i++)
            {
                TabPermissionInfo objTabPerm = (TabPermissionInfo) TabPermissions[i];
                this.Add(objTabPerm);
            }
        }

        public TabPermissionCollection(ArrayList TabPermissions, int TabId)
        {
            int refIntHelperL0 = TabPermissions.Count - 1;
            for (int i = 0; i <= refIntHelperL0; i++)
            {
                TabPermissionInfo objTabPerm = (TabPermissionInfo) TabPermissions[i];
                if (objTabPerm.TabID == TabId)
                {
                    this.Add(objTabPerm);
                }
            }
        }

        public int Add(TabPermissionInfo value)
        {
            return this.List.Add(value);
        }

        public bool CompareTo(TabPermissionCollection objTabPermissionCollection)
        {
            IEnumerator refObjectHelperL0=null;
            if (objTabPermissionCollection.Count != this.Count)
            {
                return false;
            }
            this.InnerList.Sort(new CompareTabPermissions());
            objTabPermissionCollection.InnerList.Sort(new CompareTabPermissions());
            try
            {
                refObjectHelperL0 = objTabPermissionCollection.GetEnumerator();
                int i=0;
                while (refObjectHelperL0.MoveNext())
                {
                    
                    TabPermissionInfo objTabPermission = (TabPermissionInfo) refObjectHelperL0.Current;
                    if ((objTabPermissionCollection[i].TabPermissionID != this[i].TabPermissionID) | (objTabPermissionCollection[i].AllowAccess != this[i].AllowAccess))
                    {
                        return false;
                    }
                    i++;
                }
            }
            finally
            {
                if (refObjectHelperL0 is IDisposable)
                {
                    (refObjectHelperL0 as IDisposable).Dispose();
                }
            }
            return true;
        }

        public bool Contains(TabPermissionInfo value)
        {
            return this.List.Contains(value);
        }

        public int IndexOf(TabPermissionInfo value)
        {
            return this.List.IndexOf(value);
        }

        public void Insert(int index, TabPermissionInfo value)
        {
            this.List.Insert(index, value);
        }

        public void Remove(TabPermissionInfo value)
        {
            this.List.Remove(value);
        }

        public TabPermissionInfo this[int index]
        {
            get
            {
                return (TabPermissionInfo) this.List[index];
            }
            set
            {
                this.List[index] = value;
            }
        }
    }
}

